class Solution {
public:
    int findMaxForm(vector<string>& strs, int m, int n) {
        vector<vector<int>> dp(m + 1 , vector<int>(n + 1 , 0));
        for(int i = 1; i <= strs.size(); ++i){
            int zero  = 0, one = 0;
            for(const auto &c : strs[i-1])  c == '0' ? ++zero : ++one;
            for(int j = m; j >= zero; --j){
                for(int k = n; k >= one; --k){
                    if(dp[j][k] < 1+dp[j-zero][k-one]) dp[j][k] = 1+dp[j-zero][k-one];
                }
            }
        }
        return dp[m][n];
    }
};